package com.zh.juc.interrupt;

/**
 * @Author: zhanghuan
 * @date: 2022/10/11 20:41
 * @description: create it
 * <p>
 * *  Thread.interrupted() 静态方法 判断线程是否被中断并清除中断状态
 * *  * 1.返回当前线程的中断状态，测试当前线程是否被中断
 * *  * 2。将当前线程的中断状态清零并重新设置为false，清除线程的中断状态
 */
public class InterruptDemo4 {
    public static void main(String[] args) {
        System.out.println(Thread.currentThread().getName() + "\t" + Thread.interrupted());//false
        System.out.println(Thread.currentThread().getName() + "\t" + Thread.interrupted());//false
        System.out.println("1-------------");
        Thread.currentThread().interrupt();// 中断标志位设置为true
        System.out.println("2----------");
        System.out.println(Thread.currentThread().getName() + "\t" + Thread.interrupted());//true
        System.out.println(Thread.currentThread().getName() + "\t" + Thread.interrupted());//false
    }
}
